import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from "@/views/Home.vue";
import Index from "@/views/views2/Index";
import NotFound from "@/views/NotFound";
import AdminHome from "@/views/AdminHome";
import Main from "@/views/views2/Main";
import Edit from "@/views/views2/Edit";
import Review from "@/views/views2/Review";
import News from "@/views/views2/News";
import DepartmentSelector from '@/views/views2/DepartmentSelector.vue';
import CaptainEmail from '@/views/views2/CaptainEmail.vue';
import UserManager from '@/views/views2/UserManager.vue';
import DutySchedule from '@/views/views2/DutySchedule.vue';
import NewsCount from '@/views/views2/NewsCount.vue';
import ThematicManager from '@/views/views2/ThematicManager.vue';
import FireNews from '@/views/view3/FireNews.vue';
import MechanismDynamics from '@/views/view3/MechanismDynamics.vue';
import LeaderTalk from '@/views/view3/LeaderTalk.vue';
import DownLoad from '@/views/view3/DownLoad.vue';
import ViewPoint from '@/views/view3/ViewPoint.vue';
import OnlineSubmit from '@/views/view3/OnlineSubmit.vue';
import MechanismFile from '@/views/view3/MechanismFile.vue';
import WorkPaper from '@/views/view3/WorkPaper.vue';
import WorkTalk from '@/views/view3/WorkTalk.vue';
import MediaFocus from '@/views/view3/MediaFocus.vue';
import SpecialPaper from '@/views/view3/SpecialPaper.vue';
import LocalNews from '@/views/view3/LocalNews.vue';
import PoliceCulture from '@/views/view3/PoliceCulture.vue';
import NoticePublic from '@/views/view3/NoticePublic.vue';
import StatesmanEmail from '@/views/views2/StatesmanEmail.vue';
import CommissionEmail from '@/views/views2/CommissionEmail.vue';
import PoliticsEmail from '@/views/views2/PoliticsEmail.vue';
import PoliticalMail from '@/views/view3/PoliticalMail.vue';
import CommanderMail from '@/views/view3/CommanderMail.vue';
import DisciplinaryMail from '@/views/view3/DisciplinaryMail.vue';
import DepartmentMail from '@/views/view3/DepartmentMail.vue';
import PreView from '@/views/views2/PreView.vue';
import FirstView from '@/views/views2/FirstView.vue';



Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
//解决vue路由重复导航错误
//获取原型对象上的push函数
const routes = [
    { path: '/', redirect: '/home' },
    {
        path: '/admin',
        component: AdminHome,
        children: [
            {
                path: '/admin',
                redirect: 'main'
            },
            {
                path: 'main',
                component: Main
            },
            {
                path: 'edit',
                name: 'EditArticle',
                component: Edit
            },
            {
                path: 'preview',
                name:'ViewArticle',
                component: PreView
            },
            {
                path: 'review',
                component: Review
            },
            {
                path: 'departmentselector',
                component: DepartmentSelector
            },
            {
                path: 'statesmanemail',
                component: StatesmanEmail
            },
            {
                path: 'captainemail',
                component: CaptainEmail
            },
            {
                path: 'commissionemail',
                component: CommissionEmail
            },
            {
                path: 'politicsemail',
                component: PoliticsEmail
            },
            {
                path: 'usermanager',
                component: UserManager
            },
            {
                path: 'dutyschedule',
                component: DutySchedule
            },
            {
                path: 'newscount',
                component: NewsCount
            },
            {
                path: 'thematicmanager',
                component: ThematicManager
            }
        ]
    },
    {
        path: '/home',
        component: Home,
        children: [
            {
                path: '/home',
                redirect: 'index'
            },
            {
                path: 'index',
                component: Index
            },
            {
                path: 'news',
                component: News
            },
            {
                path: 'firenews',
                component: FireNews
            },
            {
                path: 'mechanismdynamivs',
                component: MechanismDynamics
            },
            {
                path: 'leadertalk',
                component: LeaderTalk
            },
            {
                path: 'download',
                component: DownLoad
            },
            {
                path: 'viewpoint',
                component: ViewPoint
            },
            {
                path: 'onlinesubmit',
                component: OnlineSubmit
            },
            {
                path: 'mechanismfile',
                component: MechanismFile
            },
            {
                path: 'workpaper',
                component: WorkPaper
            },
            {
                path: 'worktalk',
                component: WorkTalk
            },
            {
                path: 'mediafocus',
                component: MediaFocus
            },
            {
                path: 'specialpaper',
                component: SpecialPaper
            },
            {
                path: 'noticepublic',
                component: NoticePublic
            },
            {
                path: 'localnews',
                component: LocalNews
            },
            {
                path: 'policeculture',
                component: PoliceCulture
            },
            {
                path: 'politicalmail',
                component: PoliticalMail
            },
            {
                path: 'commandermail',
                component: CommanderMail
            },
            {
                path: 'disciplinarymail',
                component: DisciplinaryMail
            },
            {
                path: 'departmentmail',
                component: DepartmentMail
            },
            {
                path: 'firstview',
                component: FirstView
            },
        ]
    },


    { path: '*', component: NotFound }
]

const router = new VueRouter({
    mode: 'hash',
    base: process.env.BASE_URL,
    routes
})

export default router
